.. _Introduction to the Python API Compression:

Introduction to the Python API for NeurEco Compression
======================================================

.. note::

  The GUI functionality **Export NeurEco to Python** , see :std:ref:`Export Tabular Compression from the GUI to the Python API`, facilitates the initial transition from the usage of NeurEco with the GUI to its usage with the Python API.


.. include:: ../../CommonParts/Introduction to the Python API Tabular.rst

To initialize a NeurEco object to handle the **Compression** problem:

.. code-block:: python

    model = Tabular.Compressor()

All the methods provided by the **Compressor** class, can be viewed by calling the *__method__* attributes:

.. code-block:: python

    print(model.__methods__)

.. code-block:: text
    
    **** NeurEco Tabular Compressor methods: ****
    - load
    - save
    - delete
    - evaluate
    - build
    - get_input_count
    - get_output_count
    - load_model_from_checkpoint
    - get_number_of_networks_from_checkpoint
    - get_weights
    - export_fmu
    - export_c
    - export_onnx
    - export_vba
    - compute_error
    - separate_models
    - concatenate_models
    - plot_network
    - plot_compression_coefficients
    - forward_derivative
    - gradient
    - set_weightsplot_compression_coefficients
    - perform_input_sweep

To understand what each parameter of any method does and how to use it simply print the doc of the method:

.. code-block:: python

    print(model.export_c.__doc__)

.. code-block:: text

    exports a NeurEco tabular model to a header file
    :param h_file_path: path where the .h file will be saved
    :param precision: string: optional: "float" or "double": precision of the weights in the h file
    :return: export_status: int: 0 if export is ok, other if otherwise.
	
.. note::

    In addition to these method, *embed* license allows to convert a NeurEco Tabular model to a Keras model, see :std:ref:`Convert a NeurEco Compression model to a Keras model`.
	
